-- open_door
-- create by cheny3
-- 找钥匙开门

return {
    -- 判断
    canTrigger = function(args)
        return true;
    end,

    -- 触发
    trigger = function(args)
        -- 找钥匙，并开门
        for pos = 1, GRID_SIZE do
            local grid = DungeonM.getGridByPos(pos);
            if grid.has_key and not grid.picked
                and (not grid.monster or grid.monster:isDead()) then
                -- 捡钥匙
                DungeonActionM.go("pick_item", pos);
                EventMgr.fire(event.PLAYER_MOVE, pos);
                return true;
            end
        end

        return false;
    end,
};
